<%--                                                                       --%>
<%-- Copyright (c) 2004-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import = "java.util.Locale" %>
<%@ page import = "java.util.Date" %>
<%@ page import = "java.text.DateFormat" %>
<%@ page import = "java.text.SimpleDateFormat" %>
<%@ page import = "java.text.FieldPosition" %>
<%@ page import = "javax.servlet.http.HttpSession" %>
<%@ page import = "org.apache.struts.Globals" %>

<%

Locale defaultLocale = Locale.getDefault();
HttpSession thisSession = request.getSession();
Locale locale = (Locale) thisSession.getAttribute(Globals.LOCALE_KEY);
if (locale == null) {
  locale = defaultLocale;
}

SimpleDateFormat formatter = new SimpleDateFormat("MMMM", locale);
Date dummy = new Date();
dummy.setDate(1);  // initialize to the first of the month

StringBuffer s = new StringBuffer();
for (int monthIndex = 0; monthIndex < 12; monthIndex++) {
  dummy.setMonth(monthIndex);
  String monthName = formatter.format(dummy);
  s.append(", '");
  s.append(monthName);
  s.append("'"); 
}
String monthNames = s.substring(2);

formatter = new SimpleDateFormat("EE", locale);
dummy.setMonth(0);   // 01/01/1995 = Sunday
dummy.setDate(1);
dummy.setYear(95);

s = new StringBuffer();
for (int weekdayIndex = 0; weekdayIndex < 7; weekdayIndex++) {
  dummy.setDate(weekdayIndex+1);
  s.append(", '");
  s.append(formatter.format(dummy));
  s.append("'"); 
}
String weekdayNames = s.substring(2);

DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
FieldPosition yearPosition = new FieldPosition(DateFormat.YEAR_FIELD);
FieldPosition monthPosition = new FieldPosition(DateFormat.MONTH_FIELD);
FieldPosition datePosition = new FieldPosition(DateFormat.DATE_FIELD);

StringBuffer yearBuf = new StringBuffer();
StringBuffer monthBuf = new StringBuffer();
StringBuffer dateBuf = new StringBuffer();

Date dtToday = new Date();

df.format(dtToday, yearBuf, yearPosition);
df.format(dtToday, monthBuf, monthPosition);
df.format(dtToday, dateBuf, datePosition);

int yPos = yearPosition.getBeginIndex();
int mPos = monthPosition.getBeginIndex();
int dPos = datePosition.getBeginIndex();

String dateOrder = "MDY";
if ((dPos < mPos) && (mPos < yPos)) dateOrder = "DMY";
else if ((yPos < mPos) && (mPos < dPos)) dateOrder = "YMD";
else if ((yPos < dPos) && (dPos < mPos)) dateOrder = "YDM";


String prevImg = "<img src=\"" + request.getContextPath() + "/mc/images/build/arrow_left_blue.gif\" width=11 height=12 border=0 vspace=0 hspace=0 alt=\"\" title=\"\">";
String nextImg = "<img src=\"" + request.getContextPath() + "/mc/images/build/arrow_right_blue.gif\" width=11 height=12 border=0 vspace=0 hspace=0 alt=\"\" title=\"\">";

%>

<script language="JavaScript">

//
//
//
function DateLocale() {

  this.monthNames = new Array ( <%= monthNames %> );
  this.weekdayNames = new Array ( <%= weekdayNames %> );
  this.dateOrder = '<%= dateOrder %>';

  this.prevImg = '<%= prevImg %>';
  this.nextImg = '<%= nextImg %>';


  // Define the "methods"
  this.getMonthNames = _dateLocale__getMonthNames;
  this.getWeekdayNames = _dateLocale__getWeekdayNames;
  this.getDateOrder = _dateLocale__getDateOrder;
  this.getPrevImg = _dateLocale__getPrevImg;
  this.getNextImg = _dateLocale__getNextImg;

}

//
//
//
function _dateLocale__getMonthNames() {
  return this.monthNames;
}

//
//
//
function _dateLocale__getWeekdayNames() {
  return this.weekdayNames;
}

//
//
//
function _dateLocale__getDateOrder() {
  return this.dateOrder;
}

//
//
//
function _dateLocale__getPrevImg() {
  return this.prevImg;
}

//
//
//
function _dateLocale__getNextImg() {
  return this.nextImg;
}

</script>
